<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>动态添加文本框</title>
    <style>
        /* 基础样式 */
        body {
            font-family: Arial, sans-serif;
            padding: 20px;
        }

        #container {
            margin-top: 20px;
        }

        .text-box {
            margin: 10px 0;
            padding: 8px;
            width: 250px;
            display: block;
        }

        button {
            padding: 10px 20px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }

        button:hover {
            background-color: #45a049;
        }
    </style>
</head>
<body>
    <!-- 添加按钮 -->
    <button onclick="addTextBox()">添加文本框</button>
    
    <!-- 文本框容器 -->
    <div id="container"></div>

    <script>
        // 计数器用于生成唯一ID
        let counter = 1;

        function addTextBox() {
            // 创建新的input元素
            const newInput = document.createElement('input');
            newInput.type = 'text';
            newInput.className = 'text-box';
            newInput.placeholder = '文本框 ' + counter;
            
            // 将新元素添加到容器中
            document.getElementById('container').appendChild(newInput);
            
            // 增加计数器
            counter++;
        }
    </script>
</body>
</html>